package com.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mall.db.domain.Member;
import com.mall.db.service.MemberService;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/uc")
public class UserVipController extends BaseController<Member> {
    @Resource(name = "memberService")
    private MemberService ms;

    @Override
    public Map<String, Object> find(Member member) {

        //实现分页
        PageHelper.startPage(member.getPage(), member.getLimit());

        QueryWrapper<Member> qw = new QueryWrapper<>();
        if (!StringUtils.isEmpty(member.getRoleIds())){
            qw.eq("role_ids",member.getRoleIds());
        }

        List<Member> list = ms.list(qw);

        PageInfo<Member> page = new PageInfo<>(list,member.getLimit());

        return this.findMap(page.getList(),page.getTotal());
    }

    @Override
    public Map<String, Object> update(Member member) {

        boolean b = ms.updateById(member);
        return this.iud("编辑",b,member);
    }




}

